<?php
registerTable("home_activity_comment", new table_home_activity_comment());

class table_home_activity_comment extends Database
{

    public function __construct()
    {
        parent::__construct("home_activity_comment");
    }

    public function fetch_root_by_aid($aid)
    {
        return $this->fetch_all_assoc("`aid`=$aid AND `parent_cid`=-1", "*", "ORDER BY `date` DESC");
    }

    public function fetch_by_aid($aid)
    {
        return $this->fetch_all_assoc("`aid`=$aid", "*", "ORDER BY `date` DESC");
    }

    public function fetch_by_parent_cid($parent_cid)
    {
        return $this->fetch_all_assoc("`parent_cid`=$parent_cid", "*", "ORDER BY `date` DESC");
    }

    public function remove_by_parent_cid($parent_cid)
    {
        return $this->remove("`parent_cid`=$parent_cid");
    }
    
    public function remove_by_cid($cid)
    {
        return $this->remove("`cid`=$cid");
    }

    public function remove_by_aid($aid)
    {
        return $this->remove("`aid`=$aid");
    }

    public function count_by_aid($aid)
    {
        $this->fetch_all("`aid`=$aid", "`aid`");
        return $this->getRows();
    }
    
    public function fetch_by_cid($cid)
    {
        return $this->fetch_assoc("`cid`='$cid'");
    }
}
?>